//app.js hello
App({
  data:{
    userInfo:[],
    url:"https://www.mf.seleted.cn/api",
    openid:'',
    out:'',
    code:''
  },
  onLaunch: function () {
    var that =this;
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    
    wx.login({
      success: res => {

        this.data.code = res.code
        wx.setStorageSync("code",res.code)
      }
    })

    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          wx.login({
            success:res =>{
            }
          })
        }
      }
    })
  },
  getHeader: function () {
    var that = this;
    var openid = wx.getStorageSync('openid');//本地取存储的sessionID
    if (openid != "" && openid != null) {
      openid =that.data.openid
      var header = { 'content-type': 'application/x-www-form-urlencoded', 'openid': openid}
    } else {
      var header = { 'content-type': 'application/x-www-form-urlencoded', 'openid': openid}
    }
    return header;
  },
  globalData: {
    userInfo: null
  },
  database: [50, 60, 55, 55, 58]
})